package org.gruposp2p.dnie.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.gruposp2p.dnie.model.xmladapter.DNIeSignedDocumentAdapter;
import org.gruposp2p.dnie.model.xmladapter.DNIeUserAdapter;
import org.gruposp2p.dnie.model.xmladapter.DateAdapter;

/**
 *
 * @author jj
 */
@XmlType
@XmlRootElement(name = "DNIeSignedDocumentComment")
@XmlAccessorType(XmlAccessType.NONE)
@Entity
@Table(name = "DNIESIGNEDDOCUMENTCOMMENT", catalog = "DNIE")
@NamedQueries({
    @NamedQuery(name = "DNIeSignedDocumentComment.findAll", query = "SELECT d FROM DNIeSignedDocumentComment d"),
    @NamedQuery(name = "DNIeSignedDocumentComment.findById", query = "SELECT d FROM DNIeSignedDocumentComment d WHERE d.id = :id"),
    @NamedQuery(name = "DNIeSignedDocumentComment.findByDate", query = "SELECT d FROM DNIeSignedDocumentComment d WHERE d.date = :date")})
public class DNIeSignedDocumentComment implements Serializable {
    
    private static final long serialVersionUID = 1L;

    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    @XmlElement
    private Integer id;
    @Basic(optional = false)
    @Lob
    @Column(name = "CONTENT", nullable = false)
    @XmlElement
    private String content;
    @Basic(optional = false)
    @Column(name = "DATE", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    @XmlElement
    @XmlJavaTypeAdapter(DateAdapter.class)
    private Date date;
    @JoinColumn(name = "DNIESIGNEDDOCUMENT_ID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private DNIeSignedDocument dnieSignedDocumentId;
    @JoinColumn(name = "DNIEUSER_ID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private DNIeUser dnieUserId;

    public DNIeSignedDocumentComment() {
    }

    public DNIeSignedDocumentComment(Integer id) {
        this.id = id;
    }

    public DNIeSignedDocumentComment(Integer id, String content, Date date) {
        this.id = id;
        this.content = content;
        this.date = date;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public DNIeSignedDocument getDNIeSignedDocumentId() {
        return dnieSignedDocumentId;
    }

    public void setDNIeSignedDocumentId(DNIeSignedDocument dnieSignedDocumentId) {
        this.dnieSignedDocumentId = dnieSignedDocumentId;
    }

    public DNIeUser getDNIeUserId() {
        return dnieUserId;
    }

    public void setDNIeUserId(DNIeUser dnieUserId) {
        this.dnieUserId = dnieUserId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DNIeSignedDocumentComment)) {
            return false;
        }
        DNIeSignedDocumentComment other = (DNIeSignedDocumentComment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dniedatabasemodel01.DNIeSignedDocumentComment[id=" + id + "]";
    }

}
